<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="app">
<comp></comp>
<comp></comp>
<comp></comp>
<comp></comp>
</div>
<template id="comp">
    <div>
        <h1>当前数据：{{counter}}</h1>
        <button @click="add">+</button>
        <button @click="sub">-</button>
    </div>
</template>
<script>
    Vue.component('comp',{
        template:'#comp',
        data(){
            return{
                counter:0
            }
        },
        methods:{
            add(){
                this.counter++
            },
            sub(){
                this.counter--
            }
        }
    })
    let app = new Vue({
        el:'#app',
    })
</script>
</body>
</html>
